package com.marketing.tenant.entity;

import com.baomidou.mybatisplus.annotation.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * 租户使用统计实体类
 * 对应数据库表：saas_usage_statistics
 */
@TableName("saas_usage_statistics")
public class TenantUsage {

    /**
     * 使用统计ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 租户ID
     */
    @NotNull(message = "租户ID不能为空")
    @TableField("tenant_id")
    private Long tenantId;

    /**
     * 统计日期
     */
    @NotNull(message = "统计日期不能为空")
    @TableField("stat_date")
    private LocalDate statDate;

    /**
     * 指标名称
     */
    @NotNull(message = "指标名称不能为空")
    @Size(max = 50, message = "指标名称长度不能超过50个字符")
    @TableField("metric_name")
    private String metricName;

    /**
     * 指标值
     */
    @TableField("metric_value")
    private Long metricValue = 0L;

    /**
     * 单位
     */
    @Size(max = 20, message = "单位长度不能超过20个字符")
    private String unit;

    /**
     * 描述
     */
    @Size(max = 255, message = "描述长度不能超过255个字符")
    private String description;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    // 关联对象
    /**
     * 租户信息（关联查询时使用）
     */
    @TableField(exist = false)
    private Tenant tenant;
    
    // 手动添加getter和setter方法
    public Long getId() {
        return id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    public Long getTenantId() {
        return tenantId;
    }
    
    public void setTenantId(Long tenantId) {
        this.tenantId = tenantId;
    }
    
    public LocalDate getStatDate() {
        return statDate;
    }
    
    public void setStatDate(LocalDate statDate) {
        this.statDate = statDate;
    }
    
    public String getMetricName() {
        return metricName;
    }
    
    public void setMetricName(String metricName) {
        this.metricName = metricName;
    }
    
    public Long getMetricValue() {
        return metricValue;
    }
    
    public void setMetricValue(Long metricValue) {
        this.metricValue = metricValue;
    }
    
    public String getUnit() {
        return unit;
    }
    
    public void setUnit(String unit) {
        this.unit = unit;
    }
    
    public String getDescription() {
        return description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public LocalDateTime getCreateTime() {
        return createTime;
    }
    
    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }
    
    public LocalDateTime getUpdateTime() {
        return updateTime;
    }
    
    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }
    
    public Tenant getTenant() {
        return tenant;
    }
    
    public void setTenant(Tenant tenant) {
        this.tenant = tenant;
    }
    
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TenantUsage that = (TenantUsage) o;
        return Objects.equals(id, that.id) &&
                Objects.equals(tenantId, that.tenantId) &&
                Objects.equals(statDate, that.statDate) &&
                Objects.equals(metricName, that.metricName) &&
                Objects.equals(metricValue, that.metricValue) &&
                Objects.equals(unit, that.unit) &&
                Objects.equals(description, that.description) &&
                Objects.equals(createTime, that.createTime) &&
                Objects.equals(updateTime, that.updateTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, tenantId, statDate, metricName, metricValue, unit, description, createTime, updateTime);
    }

    @Override
    public String toString() {
        return "TenantUsage{" +
                "id=" + id +
                ", tenantId=" + tenantId +
                ", statDate=" + statDate +
                ", metricName='" + metricName + '\'' +
                ", metricValue=" + metricValue +
                ", unit='" + unit + '\'' +
                ", description='" + description + '\'' +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }
}